package com.toubutu.audio.dto;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.toubutu.audio.common.QueryBaseDto;
import com.toubutu.audio.entity.Video;
import com.toubutu.common.BaseDto;
import com.toubutu.constants.BaseConstants;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotBlank;

/**
 * @author 戒躁
 * @version 1.0
 * @date 2024年02月23日 19:01
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class PageQueryVideoDto extends QueryBaseDto<Video> {
    private Integer categoryId;
    @NotBlank(message = "搜索关键字不能为空")
    private String videoName;

    private boolean isDeepCategory = true;

    @Override
    public LambdaQueryWrapper<Video> getWrapper() {
        LambdaQueryWrapper<Video> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Video::getIsDelete, BaseConstants.NO);
        if (categoryId!=null){
            queryWrapper.eq(Video::getCategoryId,categoryId);
        }
        if (StringUtils.isNotBlank(videoName)){
            queryWrapper.like(Video::getVideoName,videoName);
        }
        return queryWrapper;
    }
}
